<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>
      Pomelo
    </title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta http-equiv="content-style-type" content="text/css" />
    <meta http-equiv="content-scripte-type" content="text/javascript" />
    <meta name="author" content="netease" />
    <meta name="version" content="1.0" />
    <meta name="keywords" content="pomelo" />
    <link type="text/css" rel="stylesheet" href="css/base.css" />
    <script src="js/lib/build/build.js" type="text/javascript"></script>
    <script type="text/javascript">
      require('boot');
    </script> 
    <script type="text/javascript">
      var pomelo = window.pomelo;
      var host = "120.78.187.63";
      host = "127.0.0.1"
      var port = "3010";
      //获取在线人数
      var getOnlineNum = function() {
          pomelo.request("connector.entryHandler.getOnlineNum",{}, function(data) {
              console.log(data)
          });
      }
      //获取南海网疫情数据
      var getDataBynhw = function() {
          pomelo.request("connector.entryHandler.getDataBynhw",{}, function(data) {
              console.log(data)
          });
      }
      //获取疫情数据
      var getEpidemicData = function() {
          pomelo.request("connector.entryHandler.getEpidemicData",{}, function(data) {
              console.log(data)
          });
      }
      //转接HTTPS接口
      var getHttpsData = function(url) {
          pomelo.request("connector.entryHandler.getHttpsData",{url : url}, function(data) {
              console.log(data)
          });
      }
      //转接HTTP接口
      var getHttpData = function(url) {
          pomelo.request("connector.entryHandler.getHttpData",{url : url}, function(data) {
              console.log(data)
          });
      }
      //获取tick
      var getTick = function() {
          pomelo.request("connector.entryHandler.getTicket",null, function(data) {
              console.log(data)
          });
      }
      //h5登录
      var h5Enter = function(code,appid) {
          pomelo.request("connector.entryHandler.h5Enter",{code : code,appid : appid}, function(data) {
              console.log(data)
          });
      }
      //小游戏登录
      var miniEnter = function(code,appid) {
          pomelo.request("connector.entryHandler.miniEnter",{code : code,appid : appid}, function(data) {
              console.log(data)
          });
      }
      //小游戏获取unionid
      var miniEnter = function(openid,session_key,encryptedData,iv) {
          pomelo.request("connector.entryHandler.miniEnter",{openid : openid,session_key : session_key,encryptedData:encryptedData,iv:iv}, function(data) {
              console.log(data)
          });
      }
      //app登录
      var appEnter = function(code,appid) {
          pomelo.request("connector.entryHandler.appEnter",{code : code,appid : appid}, function(data) {
              console.log(data)
          });
      }
      //登录 unionid为用户唯一标识   首次登录后会生成uid为玩家ID
      var entry = function(unionid) {
          pomelo.init({
            host: host,
            port: port,
            log: true
          },function() {
            pomelo.request("connector.entryHandler.entryAccount",{unionid : unionid}, function(data) {
                console.log(data);
            });
          })
      }
      //改变日排行榜
      var changeDayRank = function(ustr,gameType,score) {
          pomelo.request("connector.rankHandler.changeDayRank",{ustr : ustr,gameType : gameType,score : score}, function(data) {
              console.log(data);
          });
      }
      //获取今日排行榜
      var getDayRank = function(gameType,count) {
          pomelo.request("connector.rankHandler.getDayRank",{gameType : gameType,count : count}, function(data) {
              console.log(data);
          });
      }
      //获取昨日排行榜
      var getYesterdayRank = function(gameType,count) {
          pomelo.request("connector.rankHandler.getYesterdayRank",{gameType : gameType,count : count}, function(data) {
              console.log(data);
          });
      }
      //改变持久排行榜
      var changeDurableRank = function(ustr,gameType,score) {
          pomelo.request("connector.rankHandler.changeDurableRank",{ustr : ustr,gameType : gameType,score : score}, function(data) {
              console.log(data);
          });
      }
      //获取持久排行榜
      var getDurableRank = function(gameType,count) {
          pomelo.request("connector.rankHandler.getDurableRank",{gameType : gameType,count : count}, function(data) {
              console.log(data);
          });
      }
      //加入匹配
      var joinMatch = function(gameType) {
          pomelo.request("connector.matchHandler.joinMatch",{gameType : gameType}, function(data) {
              console.log(data);
          });
      }
      //离开匹配
      var leaveMatch = function() {
          pomelo.request("connector.matchHandler.leaveMatch",{}, function(data) {
              console.log(data);
          });
      }
      //关闭房间
      var closeRoom = function() {
          pomelo.request("connector.matchHandler.closeRoom",{}, function(data) {
              console.log(data);
          });
      }
      //发送消息
      var sendMessage = function(text) {
          pomelo.request("connector.matchHandler.sendMessage",{text : text}, function(data) {
              console.log(data);
          });
      }
      //保存房间数据
      var saveRoomData = function(key,value) {
          pomelo.request("connector.matchHandler.saveRoomData",{key : key,value : value}, function(data) {
              console.log(data);
          });
      }
      //获取全部房间数据
      var getRoomData = function() {
          pomelo.request("connector.matchHandler.getRoomData",{}, function(data) {
              console.log(data);
          });
      }
      //设置个人结算天梯积分
      var setUserSettleScore = function(gameType,score) {
          pomelo.request("connector.matchHandler.setUserSettleScore",{gameType : gameType,score : score}, function(data) {
              console.log(data);
          });
      }
      //获取天梯积分
      var getUserScore = function(gameType) {
          pomelo.request("connector.matchHandler.getUserScore",{gameType : gameType}, function(data) {
              console.log(data);
          });
      }
      //保存用户数据,key 与 value 均为string   若需要保存其他类型   先使用JSON.stringify转化为string
      var saveUserData = function(key,value) {
          pomelo.request("connector.userHandler.saveUserData",{key : key,value : value}, function(data) {
              console.log(data);
          });
      }
      //批量保存数据 datas为object    key与value规则与上面一致
      var saveBatchUserData = function(datas) {
          pomelo.request("connector.userHandler.saveBatchUserData",{datas : datas}, function(data) {
              console.log(data);
          });
      }
      //获取用户数据
      var getUserData = function(key) {
          pomelo.request("connector.userHandler.getUserData",{key : key}, function(data) {
              console.log(data);
          });
      }
      //获取用户全部数据
      var getUserAllData = function() {
          pomelo.request("connector.userHandler.getUserAllData",{}, function(data) {
              console.log(data);
          });
      }
      //清除单条用户数据
      var deleteUserData = function(key) {
          pomelo.request("connector.userHandler.deleteUserData",{key : key}, function(data) {
              console.log(data);
          });
      }
      //清除全部用户数据
      var deleteAllUserData = function() {
          pomelo.request("connector.userHandler.deleteAllUserData",{}, function(data) {
              console.log(data);
          });
      }
      //提交答案
      var submitAnswer = function(answer) {
          pomelo.request("connector.matchHandler.roomCmd",{cmd : "submitAnswer",answer : answer}, function(data) {
              console.log(data);
          });
      }
      //获取房间信息
      var getRoomInfo = function() {
          pomelo.request("connector.matchHandler.roomCmd",{cmd : "getRoomInfo"}, function(data) {
              console.log(data);
          });
      }
      //接收信息
      pomelo.on("onMessage",function(data) {
        console.log("onMessage")
        console.log(data)
      })
    </script>
  </head>
  <body>
    <div class="g-doc">
      <div class="g-banner" style="border:none">
        <div class="logo">
          <div class="img"></div>
        </div>
      </div>
      <div class="g-background">
        <div class="g-content">
          Welcome to Pomelo
        </div>
      </div>
      <div class="g-link">
        Home:
        <a href="https://github.com/NetEase/pomelo">https://github.com/NetEase/pomelo</a>
      </div>
      <div class="g-button">
        <input id="test" type="button" value="Test Game Server" onclick="show()"/>
      </div>
    </div>
  </body>
</html>
